package com.yeyi.ytest.java8;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import com.yeyi.YTool.StringUtil;

public class ArticleUtil {
    public static List<Article> randomArticles(int length, boolean isArrayList) {
        if(length<1) {
            length = 16;
        }
        List<Article> result = null;
        
        if(isArrayList) {
            result = new ArrayList<>(length);
        }else {
            result = new LinkedList<>();
        }
        for(int i=0; i<length; i++) {
            Article a = new Article(StringUtil.getRandomNumber(8),StringUtil.getRandomNumber(8),
                    randomStringListArrayList(18,isArrayList));
            result.add(a);    
        }
        return result;
    }
    
    static List<String> randomStringListArrayList(int length, boolean isArrayList){
        List<String> li = null;
        if(isArrayList) 
        {
            if(length<1) {
                length = 16;
            }
            li = new ArrayList<>(length);
        }else {
            li = new LinkedList<>();
        }
        
        for(int i=0; i<length; i++) {
            li.add(StringUtil.getRandomNumber(8));
        }
        
        return li;
    }
    
    public static void main(String[] args) {
        System.out.println(randomArticles(8,true));
    }
}
